﻿using Syspetro.Core.AppDeal;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Syspetro.Core.DbAccessor
{
    public interface IEntityBaseService<T> where T : EntityBase, new()
    {
        IRepository<T> Repository { get; }
        #region Apis
        Task<Guid> AddAsync(T model);
        Task<int> AddAsync(List<T> models);
        Task<bool> DeleteAsync(T model);
        Task<bool> DeleteAsync(Guid id);
        Task<int> DeleteAsync(Expression<Func<T, bool>> expression);
        Task<bool> UpdateAsync(T model);
        Task<bool> UpdateAsync<V>(V model, Expression<Func<T, bool>> expression) where V : class, new();
        Task<bool> UpdateAsync(T model, Expression<Func<T, object>> properties, bool isIgnore = false);
        Task<int> UpdateAsync(T model, Expression<Func<T, bool>> expression, Expression<Func<T, object>> properties);
        Task<bool> AnyAsync(Expression<Func<T, bool>> expression);
        Task<T> GetAsync(Guid id);
        Task<V> GetDtoAsync<V>(Guid id) where V : class, new();
        Task<List<T>> FindAsync(Expression<Func<T, bool>> expression, IOrderByReq orderBy = null);
        Task<List<V>> FindDtoAsync<V>(Expression<Func<T, bool>> expression, IOrderByReq orderBy = null) where V : class, new();
        Task<PageList<T>> FindPageAsync(IPageReq<T> req);
        Task<PageList<V>> FindPageAsync<V>(IPageReq<T> req) where V : class, new();
        #endregion
    }
}
